// 原型式继承
function object(o) {
	//临时性构造函数
	function F() {}
	//将传入对象作为构造函数的原型
	F.prototype = o;
	return new F();
}

// 寄生组合继承
function inheritPrototype(subType, superType) {
	// 创建对象
	let prototype = object(superType.prototype);
	// 增强对象
	prototype.constructor = subType;
	// 指定对象
	subType.prototype = prototype;
}

// 超类构造函数
function SuperType(name) {
	this.name = name;
	this.colors = ["red", "blue", "green"];
}
SuperType.prototype.sayName = function () {
	console.log(this.name);
};

// 子类型构造函数
function SubType(name, age) {
	// 借用构造函数继承
	SuperType.call(this, name);
	this.age = age;
}

inheritPrototype(SubType, SuperType);

SubType.prototype.sayAge = function () {
	console.log(this.age);
};
